{extend name="admin/public/base" /}

{block name="content"}
<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    分卷列表
    <small></small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">内容</a></li>
    <li class="active">分卷列表</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="box box-solid">
        <div class="box-header with-border">
            <a href="{:url('admin/section/create', ['id' => $data['book']['id']])}" class="btn btn-default btn-flat"><i class="fa fa-plus-square"></i> 创建分卷 </a>
            <div class="box-tools pull-right">
                <a href="javascript:history.go(-1)" class="btn btn-box-tool"><i class="fa fa-chevron-left"></i></a>
            </div>
        </div>

        <div class="box-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>#ID</th>
                            <th>标题</th>
                            <th>图书</th>
                            <th>日期</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    {volist name="data.list" id="vo"}
                    <tr id = "t_{$vo.id}">
                        <td>{$vo.id}</td>
                        <td>{$vo.title}</td>
                        <td>{$vo.book_name}</td>
                        <td>{$vo.create_at}</td>
                        <td>
                          <div class="btn-group">
                            <a href="{:url('admin/section/edit',['id'=>$vo.id])}" class="btn btn-default btn-xs"><i class="fa fa-edit"></i></a>
                            <a onClick="deleteOne({$vo.id})" class="btn btn-default btn-xs"><i class="fa fa-trash-o"></i></a>
                          </div>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>

        </div>
        <div class="box-footer">
            <div class="row">
                <div class="col-sm-6">

                </div>

                <div class="col-sm-6">
                    <div class="pull-right">
                        {$data.page}
                    </div>
                </div>
            </div>
        </div>
    </div>

</section>
<!-- /.content -->
{/block}

{block name="js"}
<script>
    function deleteOne(id){
            swal({
                title: "确定删除这条信息吗?",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: false },
            function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        url:"{:url('admin/section/remove')}",
                        data:{'id':id},
                        type:'post',
                        dataType:'json',
                        success: function(xhr){
                            if(xhr.code == 200){
                                swal(xhr.msg, "", "success");
                                $("#t_"+id).remove();
                            }else{
                                swal(xhr.msg, "", "error");
                            }
                        }
                    })
                } else {
                    swal("取消操作", "", "error");
                }
            });
    }
</script>
{/block}
